<template>
  <div>
    <contract-stat :stats="contractStats" />
    <contract-trend :months="contractTrendMonths" :series="contractTrendSeries" :legend="contractTrendLegend" />
    <div style="margin: 24px 0 8px 0; font-weight: bold; font-size: 16px;">最近收款记录</div>
    <recent-payment :data="paymentList" />
  </div>
</template>

<script>
import baseInfo from './components/baseInfo';
import gridMenu from './components/gridMenu';
import visitChart from './components/visitChart';
import userChart from './components/userChart';
import hotSearch from './hot-search';
import userPreference from './user-preference';
import contractStat from './components/contract-stat.vue';
import recentPayment from './components/recent-payment.vue';
import contractTrend from './components/contract-trend.vue';
import { auth } from '@/api/system';
import { Notice } from 'iview';
import { getCookies, setCookies } from '@/libs/util';
import { upgradeStatusApi } from '@/api/system';


export default {
  name: 'index',
  components: {
    baseInfo,
    gridMenu,
    visitChart,
    userChart,
    hotSearch,
    userPreference,
    contractStat,
    recentPayment,
    contractTrend,
  },
  data() {
    return {
      visitType: 'day', // day, month, year
      visitDate: [new Date(), new Date()],
      force_reminder: null,
      contractStats: [
        { title: '合同总数', value: 120, icon: 'md-list-box', iconColor: '#2d8cf0' },
        { title: '执行中合同', value: 45, icon: 'md-sync', iconColor: '#19be6b' },
        { title: '已完成合同', value: 60, icon: 'md-checkmark-circle', iconColor: '#ff9900' },
        { title: '最近收款合同', value: 10, icon: 'md-cash', iconColor: '#ed4014' },
        { title: '坏帐合同', value: 5, icon: 'md-alert', iconColor: '#808695' }
      ],
      paymentList: [
        { index: 1, contract_name: '合同A', company_name: '甲方A', total_amount: 100000, amount: 20000, pay_date: '2024-06-01', real_name: '张三' },
        { index: 2, contract_name: '合同B', company_name: '甲方B', total_amount: 80000, amount: 15000, pay_date: '2024-06-02', real_name: '李四' },
        { index: 3, contract_name: '合同C', company_name: '甲方C', total_amount: 120000, amount: 30000, pay_date: '2024-06-03', real_name: '王五' }
      ],
      contractTrendMonths: [
        '1月', '2月', '3月', '4月', '5月', '6月',
        '7月', '8月', '9月', '10月', '11月', '12月'
      ],
      contractTrendSeries: [
        { name: '2024年', data: [8, 10, 12, 15, 18, 20, 22, 25, 28, 30, 32, 35] },
        { name: '2025年', data: [12, 15, 18, 20, 22, 25, 30, 28, 26, 32, 35, 40] }
      ],
      contractTrendLegend: ['2023年', '2024年'],
    };
  },
  mounted() {
    this.getAuth();
  },
  methods: {
    getAuth() {
      auth()
        .then((res) => {
          let data = res.data || {};
          this.force_reminder = data.force_reminder
          if (data.auth_code && data.auth) {
            this.authCode = data.auth_code;
            this.auth = true;
          }
        })
        .catch((res) => {});
    },
  },
};
</script>

<style lang="less">
.dashboard-console-visit {
  .ivu-radio-group-button .ivu-radio-wrapper {
    border: none !important;
    box-shadow: none !important;
    padding: 0 12px;
  }
  .ivu-radio-group-button .ivu-radio-wrapper:before,
  .ivu-radio-group-button .ivu-radio-wrapper:after {
    display: none;
  }
}
</style>
